//package ycl.common.config;
//
//import com.google.common.collect.Lists;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import springfox.documentation.builders.ParameterBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.schema.ModelRef;
//import springfox.documentation.service.*;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spi.service.contexts.SecurityContext;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
//import ycl.common.constants.SecurityConstant;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @author ycl
// * @date 2022/6/20 0020 10:53:46
// */
//@Configuration
//@EnableSwagger2WebMvc
//public class SwaggerConfig {
//
//	@Bean
//	public Docket docket() {
//		String token = SecurityConstant.TOKEN;
//		String header = SecurityConstant.HEADER;
//		String loginType = SecurityConstant.LOGIN_TYPE;
//		String string = "string";
//
//		List<Parameter> list = new ArrayList<>();
//		ParameterBuilder tokenBuilder = new ParameterBuilder();
//		tokenBuilder.name(token)
//				.description("令牌")
//				.modelRef(new ModelRef(string))
//				.parameterType(header)
//				.required(false)
//				.build();
//		list.add(tokenBuilder.build());
//
//		ParameterBuilder loginTypeBuilder = new ParameterBuilder();
//		loginTypeBuilder.name(loginType)
//				.description("登录方式")
//				.modelRef(new ModelRef(string))
//				.parameterType(header)
//				.required(false)
//				.build();
//		list.add(loginTypeBuilder.build());
//
////		return new Docket(DocumentationType.SWAGGER_2)
////				.apiInfo(apiInfo())
////				.select()
////				.apis(RequestHandlerSelectors.any())
////				//不监控以下请求路径(注意不是在ApiOperation的提示名字)
////				.paths(PathSelectors.regex("(?!/health).*"))
////				.paths(PathSelectors.regex("(?!/error).*"))
////				.paths(PathSelectors.regex("(?!/actuator).*"))
////				.build()
////				.globalOperationParameters(list);
//		return new Docket(DocumentationType.SWAGGER_2)
//				.apiInfo(apiInfo())
//				.select()
//				.apis(RequestHandlerSelectors.any())
//				//不监控以下请求路径(注意不是在ApiOperation的提示名字)
//				.paths(PathSelectors.regex("(?!/health).*"))
//				.paths(PathSelectors.regex("(?!/error).*"))
//				.paths(PathSelectors.regex("(?!/actuator).*"))
//				.build()
//				.globalOperationParameters(list)
//				.securitySchemes(securitySchemes())
//				.securityContexts(securityContexts());
//	}
//
//	private List<SecurityContext> securityContexts() {
//		ArrayList<SecurityContext> list = Lists.newArrayList();
//		SecurityContext build = SecurityContext.builder()
//				.securityReferences(securityReferences())
//				.build();
//		list.add(build);
//		return list;
//	}
//
//	/**
//	 * 全局认证
//	 *
//	 * @return 认证列表
//	 */
//	private List<SecurityReference> securityReferences() {
//		AuthorizationScope scope = new AuthorizationScope("global", "accessEverything");
//		AuthorizationScope[] scopes = new AuthorizationScope[1];
//		scopes[0] = scope;
//		ArrayList<SecurityReference> list = Lists.newArrayList();
//		list.add(new SecurityReference(SecurityConstant.TOKEN, scopes));
//		list.add(new SecurityReference(SecurityConstant.LOGIN_TYPE, scopes));
//		return list;
//	}
//
//	/**
//	 * 默认请求头token
//	 *
//	 * @return 认证列表
//	 */
//	private List<SecurityScheme> securitySchemes() {
//		ArrayList<SecurityScheme> list = Lists.newArrayList();
//		list.add(new ApiKey(SecurityConstant.TOKEN, SecurityConstant.TOKEN, "header"));
//		list.add(new ApiKey(SecurityConstant.LOGIN_TYPE, SecurityConstant.LOGIN_TYPE, "header"));
//		return list;
//	}
//
//	private ApiInfo apiInfo() {
//		return new ApiInfo(
//				"YCL Spring Cloud",
//				"YCL",
//				"1.0",
//				"不告诉你",
//				new Contact("YCL", "不告诉你", "28********6@qq.com"),
//				"Apache 2.0",
//				"http://www.apache.org/licenses/LICENSE-2.0",
//				new ArrayList<>()
//		);
//	}
//}
